import store from '../store'
import router from './index'
import { getCookie } from '../util'

export default () => {
    // setCookie('token', 'KJq4iS86CXd%2Bvj4J9VC8mFCSiyp10bB4kLftWhdvBLs2ZBnOfJmjS5%2FjdE02iurMEHBJjBgN0rvq8MWcMx5C2k7p90GD2H4xt4VyzRjGEm01GMvV6jHb3zF7GX2ocMuG')
    let token = getCookie('userToken')
    store.commit('initToken', token)
    router.beforeEach((to, from, next) => {
        if (to.path !== '/loginInfo' && !token) {
            next({ path: '/loginInfo' })
            return
        }
        next()
    })
}
